package com.taxigang.client.uibinder_mobile;

import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.taxigang.client.facebook.ConnectState;

/**
 * Provides responses for queries made 
 */

public class LoginCallback implements AsyncCallback<ConnectState> {
	
	
	public LoginCallback(){
	}
	public void onFailure(Throwable caught) {
		Window.alert ( "Failed to get facebook connect status, hit reload" );
	}
	public void onSuccess(ConnectState result) {
		Window.alert("connect state="+result);
//		Log.info("GetUserDetailsCallback onSuccess connected="+(result == ConnectState.connected));
//		Authenication authenication = Authenication.getInstance();
//		//microLoadingWidget.hide();
//		if ( result == ConnectState.connected ) {
//			if (authenication.getLogedinResolved(Provider.Facebook, Status.LoggedIn)){		
//				if (authenication.getAuthStatus()==AuthStatus.LoggedInFacebook){
//					LayoutConstants.getInstance().setSession(Session.getInstance());
//
//					//Window.alert ("fb-in");
//					//dont' ask details if logged into fb
//					LoginInfo fbloginInfo = Session.getInstance().getLoginInfo();
//					fbloginInfo.setLoginProvider(Provider.Facebook.toString());
//
//					fbloginInfo.setLoggedIn(true);
//					fbloginInfo.setIsTempory(false);
//					
//					FacebookApi.waitUntilUserDetailsReady(new ThenGetUserDetails());
//
//				}
//			}
//		} else {
//			Log.info("GetUserDetailsCallback onSuccess not connected");
//			if (authenication.getLoggedoutResolved(Provider.Facebook, Status.LoggedOut)){					
//				Log.info("GetUserDetailsCallback:onSuccess:loggedoutresolved:fb");
//				//Window.alert ("fb resolved: "+result);
//				//Window.alert ( "not logged in - show login" );
//				LoginInfo loginInfo = new LoginInfo();
//				Session.getInstance().setLoginInfo(loginInfo); //TODO
//				TaxiGangPresenter.getInstance().authenticationComplete();
//
//				Log.info("GetUserDetailsCallback:onSuccess:loggedoutresolved:fb complete");
//			} else {
//				Log.info("GetUserDetailsCallback:onSuccess: !loggedoutresolved:fb");					
//			}
//		}

		//layoutWelcome(loginInfo);
	}



};
